﻿using UnityEngine;
using System.Collections;

public class Hud : MonoBehaviour
{

		public GUIStyle backgroundPlayerOne;
		public GUIStyle backgroundPlayerTwo;
		public GUIStyle backgroundPlayerThree;
		public GUIStyle backgroundPlayerFour;
		public GUIStyle backgroundLife;
		public int playerOneLife;
		public int playerTwoLife;
		public int playerThreeLife;
		public int playerFourLife;
		public GUIStyle buttonBackground;
		public float guiElementX;
		public float guiElementXWidth;
		public float guiElementY;
		public float guiElementYMargen;
		public bool guiShowElements = false;
	
		void OnGUI ()
		{
				if (guiShowElements) {
						//Mostra a tela de fundo
						if (GameController.numeroJogadores >= 1) {
								if (GUI.Button (new Rect (Screen.width * guiElementX, (Screen.height * guiElementY) + (Screen.height * guiElementYMargen), Screen.width * guiElementXWidth, Screen.height * .1f),
			                "", backgroundPlayerOne)) {
										print ("Iniciar Clicked");
								}
								if (playerOneLife > 0) {
										for (int x = 1; x<=playerOneLife; x++) {
						GUI.Button (new Rect (Screen.width * guiElementX + ((Screen.width*0.08f) * x), (Screen.height * guiElementY) + (Screen.height * guiElementYMargen), Screen.width * guiElementXWidth, Screen.height * .1f),
					            	"", backgroundLife);
										}
								}
						}

						if (GameController.numeroJogadores >= 2) {
								if (GUI.Button (new Rect (Screen.width * (guiElementX * 50), (Screen.height * guiElementY) + (Screen.height * guiElementYMargen), Screen.width * guiElementXWidth, Screen.height * .1f),
			                "", backgroundPlayerTwo)) {
										print ("Iniciar Clicked");
								}
								if (playerTwoLife > 0) {
										for (int x = 1; x<=playerTwoLife; x++) {
						GUI.Button (new Rect (Screen.width * (guiElementX * 50) + ((Screen.width*0.08f) * x), (Screen.height * guiElementY) + (Screen.height * (guiElementYMargen)), Screen.width * guiElementXWidth, Screen.height * .1f),
					            "", backgroundLife);
										}
								}
						}
						if (GameController.numeroJogadores >= 3) {
								if (GUI.Button (new Rect (Screen.width * (guiElementX * 50), (Screen.height * guiElementY) + (Screen.height * (guiElementYMargen * 4)), Screen.width * guiElementXWidth, Screen.height * .1f),
			                "", backgroundPlayerThree)) {
										print ("Iniciar Clicked");
								}
								if (playerThreeLife > 0) {
										for (int x = 1; x<=playerThreeLife; x++) {
						GUI.Button (new Rect (Screen.width * (guiElementX * 50) + ((Screen.width*0.08f) * x), (Screen.height * guiElementY) + (Screen.height * (guiElementYMargen * 4)), Screen.width * guiElementXWidth, Screen.height * .1f),
					            "", backgroundLife);
										}
								}
						}
						if (GameController.numeroJogadores >= 4) {
								if (GUI.Button (new Rect (Screen.width * guiElementX, (Screen.height * guiElementY) + (Screen.height * (guiElementYMargen * 4)), Screen.width * guiElementXWidth, Screen.height * .1f),
			                "", backgroundPlayerFour)) {
										print ("Iniciar Clicked");
								}
								if (playerFourLife > 0) {
										for (int x = 1; x<=playerFourLife; x++) {
						GUI.Button (new Rect (Screen.width * guiElementX + ((Screen.width*0.08f) * x), (Screen.height * guiElementY) + (Screen.height * (guiElementYMargen * 4)), Screen.width * guiElementXWidth, Screen.height * .1f),
					            "", backgroundLife);
										}
								}
						}

				}
		}
	
		// Use this for initialization
		void Start ()
		{
		
		}
	
		// Update is called once per frame
		void Update ()
		{
		
		}
}
